﻿<fluent:RibbonWindow x:Class="ThumbGen.ResultsListBox"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:ThumbGen"
    xmlns:fluent="clr-namespace:Fluent;assembly=Fluent"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:ad="clr-namespace:AvalonDock;assembly=AvalonDock"
    xmlns:moviesheets="clr-namespace:ThumbGen.MovieSheets"
    Title="Search results (click an item to request its image)" MinHeight="400" MinWidth="800"
    WindowStartupLocation="CenterOwner" ResizeMode="CanResize"
    ShowInTaskbar="True" x:Name="TheWindow" Width="1020" Height="750" local:WindowSettings.Save="True">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="CommonStyles.xaml"/>
            </ResourceDictionary.MergedDictionaries>

            <Style TargetType="{x:Type TabItem}"/>
            <Style TargetType="{x:Type TextBox}"/>

            <local:PosterIndexConverter x:Key="PosterIndexConverter"/>
            <BooleanToVisibilityConverter x:Key="BoolVisibilityConverter"/>
            <local:NotBoolToVisibilityConverter x:Key="NotBoolVisibilityConverter"/>
            <local:ImageLockFixConverter x:Key="ImageFixConverter"/>
            <local:Bool2StyleConverter x:Key="Bool2StyleConverter"/>
            <local:Bool2WeightConverter x:Key="Bool2WeightConverter"/>
            <local:NullImageConverter x:Key="NullImageConverter"/>

            <Style TargetType="{x:Type ListBoxItem}">
                <Setter Property="VerticalContentAlignment" Value="Stretch"/>
                <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
            </Style>

            <Style TargetType="{x:Type TreeViewItem}">
                <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/>
                <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}"/>
                <Setter Property="VerticalContentAlignment" Value="Stretch"/>
                <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
            </Style>

            <Style x:Key="CustomThumbFromDiskStyle" TargetType="{x:Type Button}">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding CollectorName}" Value="My Own Thumbnail From Disk">
                        <Setter Property="Button.Visibility" Value="Visible"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <DataTemplate DataType="{x:Type local:ResultMovieItem}">
                <StackPanel Orientation="Horizontal" Margin="5" MouseDown="StackPanel_MouseDown">
                    <Image Source="images/image.png" Margin="0 0 3 0"/>
                    <TextBlock Margin="0" Text="{Binding Path=Title}" VerticalAlignment="Center"/>
                    <TextBlock Margin="5 0 0 0" Text="{Binding Path=ExtraText}" VerticalAlignment="Center"/>
                    <Image Source="{Binding Path=LanguageImageUrl, Converter={StaticResource NullImageConverter}}" Margin="3 0 0 0" Width="16" Height="16"/>
                    <Button Margin="10 3 3 3" VerticalAlignment="Center"
                  Click="LoadImageFromDiskButton_Click" ToolTip="Load my cover from disk" Visibility="Collapsed"
                  Style="{StaticResource CustomThumbFromDiskStyle}">
                        <Image Source="/images/open.png" VerticalAlignment="Center" Width="16" Height="16"/>
                    </Button>
                </StackPanel>
            </DataTemplate>

            <HierarchicalDataTemplate DataType="{x:Type local:CollectorNode}" ItemsSource="{Binding Path=Results}">
                <StackPanel Orientation="Horizontal">
                    <Image Source="images/database.png" Margin="0 0 3 0"/>
                    <Border BorderBrush="White"  Background="Black" BorderThickness="0.75" CornerRadius="2">
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Margin="2" FontWeight="Bold" Foreground="White" Text="{Binding Name}" VerticalAlignment="Center"></TextBlock>
                            <TextBlock Margin="10 2 2 2" FontSize="9" Foreground="White" Text="{Binding Collector.SearchTime, StringFormat= \{0\}}" VerticalAlignment="Center"></TextBlock>
                        </StackPanel>
                    </Border>
                    <local:PopupInfoControl Margin="5 0 0 0" VerticalAlignment="Center"
                                          SupportsIMDbSearch="{Binding Path=Collector.SupportsIMDbSearch}"
                                          SupportsBackdrops="{Binding Path=Collector.SupportsBackdrops}"
                                          SupportsMovieInfo="{Binding Path=Collector.SupportsMovieInfo}"
                                          Country="{Binding Path=Collector.Country}"/>
                </StackPanel>
            </HierarchicalDataTemplate>

            <HierarchicalDataTemplate DataType="{x:Type local:ResultMovieFolder}" ItemsSource="{Binding Path=Images}">
                <StackPanel Orientation="Horizontal" Focusable="False">
                    <Image Source="images/movie.png" Margin="0 0 3 0"/>
                    <TextBlock Margin="2" Foreground="Black" FontWeight="Bold" Text="{Binding Title}" VerticalAlignment="Center"/>
                    <Button VerticalAlignment="Center" Margin="2 0 0 0" Click="imdbInfoButton_Click" ToolTip="Jump to IMDb.com and show movie details">
                        <Button.Style>
                            <Style>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding MovieInfo.IMDBID}" Value="{x:Null}">
                                        <Setter Property="Button.Visibility" Value="Collapsed"/>
                                    </DataTrigger>
                                </Style.Triggers>
                                <Setter Property="Button.Visibility" Value="Visible"/>
                            </Style>
                        </Button.Style>
                        <Button.Template>
                            <ControlTemplate>
                                <Image Source="Images/Imdb_small.png" Width="16" Height="16" Cursor="Hand" SnapsToDevicePixels="True" VerticalAlignment="Center"/>
                            </ControlTemplate>
                        </Button.Template>
                    </Button>
                    <Button VerticalAlignment="Center" Click="movieInfoButton_Click" Margin="3" ToolTip="Jump to image provider's website and show movie details">
                        <Button.Style>
                            <Style>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding CollectorMovieUrl}" Value="{x:Null}">
                                        <Setter Property="Button.Visibility" Value="Collapsed"/>
                                    </DataTrigger>
                                </Style.Triggers>
                                <Setter Property="Button.Visibility" Value="Visible"/>
                            </Style>
                        </Button.Style>
                        <Button.Template>
                            <ControlTemplate>
                                <Image Source="/Images/Info.png" Width="16" Height="16" Cursor="Hand" SnapsToDevicePixels="True" VerticalAlignment="Center"/>
                            </ControlTemplate>
                        </Button.Template>
                    </Button>

                </StackPanel>
            </HierarchicalDataTemplate>

        </ResourceDictionary>
    </Window.Resources>
    <Window.CommandBindings>
        <CommandBinding Command="{x:Static local:MovieInfoControl.UseMovieInfoCommand}" Executed="UseMovieInfoCommand_Executed" CanExecute="UseMovieInfoCommand_CanExecute"/>
    </Window.CommandBindings>

    <Grid x:Name="TheMainGrid">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="5"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <fluent:Ribbon Grid.Column="0" Grid.ColumnSpan="2" IsQuickAccessToolBarVisible="False" AutomaticStateManagement="true" BackstageBrush="{x:Static local:FileManager.BackstageBrush}" x:Name="TheRibbon">
            <fluent:RibbonTabItem Header="Home">
                <fluent:RibbonGroupBox Header="Layouts">
                    <local:ProfileSelector MaxWidth="200" Margin="0 5 0 5"
                          Manager="{Binding Source={x:Static local:ResultsListBox.LayoutManager}}"
                          HorizontalAlignment="Left" HeaderText="Current Layout" x:Name="LayoutSelector"/>
                </fluent:RibbonGroupBox>
                <fluent:RibbonGroupBox Header="Generate" DataContext="{Binding Source={x:Static local:FileManager.Configuration},Path=Options}">
                    <Grid x:Name="grdAutogen" VerticalAlignment="Top">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>

                        <Image Grid.Column="0" Grid.Row="0" Source="/images/image.png" Width="16" Height="16" Margin="1"
               HorizontalAlignment="Center" ToolTip="Generate thumbnail"/>
                        <CheckBox Grid.Column="0" Grid.Row="1" HorizontalAlignment="Center" IsChecked="{Binding AutogenerateThumbnail}"
                      ToolTip="Generate thumbnail"/>

                        <Image Grid.Column="1" Grid.Row="0" Source="/images/folder.png" Width="16" Height="16" Margin="1"
               HorizontalAlignment="Center" ToolTip="Generate extra thumbnail"/>
                        <CheckBox Grid.Column="1" Grid.Row="1" HorizontalAlignment="Center" IsChecked="{Binding AutogenerateFolderJpg}"
                      ToolTip="Generate extra thumbnail"/>

                        <Image Grid.Column="2" Grid.Row="0" Source="/images/movie.png" Width="16" Height="16" Margin="1"
               HorizontalAlignment="Center" ToolTip="Generate .nfo file"/>
                        <CheckBox Grid.Column="2" Grid.Row="1" HorizontalAlignment="Center" IsChecked="{Binding AutogenerateMovieInfo}"
                      ToolTip="Generate .nfo file"/>

                        <Image Grid.Column="3" Grid.Row="0" Source="/images/backdrop.png" Width="16" Height="16" Margin="1"
               HorizontalAlignment="Center" ToolTip="Generate moviesheet"/>
                        <CheckBox Grid.Column="3" Grid.Row="1" HorizontalAlignment="Center" IsChecked="{Binding AutogenerateMovieSheet}"
                      ToolTip="Generate moviesheet"/>

                        <Image Grid.Column="4" Grid.Row="0" Source="/images/moviesheet_folder.png" Width="16" Height="16" Margin="1"
               HorizontalAlignment="Center" ToolTip="Generate moviesheet for the extra location (see Advanced Options)"/>
                        <CheckBox Grid.Column="4" Grid.Row="1" HorizontalAlignment="Center" IsChecked="{Binding AutogenerateMoviesheetForFolder}"
                      ToolTip="Generate moviesheet for the extra location (see Advanced Options)"/>

                        <Image Grid.Column="5" Grid.Row="0" Source="/images/metadata.gif" Width="16" Height="16" Margin="1"
                                    HorizontalAlignment="Center" ToolTip="Generate metadata"/>
                        <CheckBox Grid.Column="5" Grid.Row="1" HorizontalAlignment="Center" IsChecked="{Binding AutogenerateMoviesheetMetadata}"
                                    ToolTip="Generate metadata"/>

                        <Image Grid.Column="6" Grid.Row="0" Source="/images/folder.png" Width="16" Height="16" Margin="1"
               HorizontalAlignment="Center" ToolTip="Generate moviesheet for the spare location (see Advanced Options)"/>
                        <CheckBox Grid.Column="6" Grid.Row="1" HorizontalAlignment="Center" IsChecked="{Binding AutogenerateMoviesheetForParentFolder}"
                      ToolTip="Generate moviesheet for the spare location (see Advanced Options)"/>

                        <Image Grid.Column="7" Grid.Row="0" Source="/images/metadata.gif" Width="16" Height="16" Margin="1"
                                    HorizontalAlignment="Center" ToolTip="Generate spare metadata"/>
                        <CheckBox Grid.Column="7" Grid.Row="1" HorizontalAlignment="Center" IsChecked="{Binding GenerateParentFolderMetadata}"
                                    ToolTip="Generate spare metadata"/>

                        <fluent:Button Grid.Column="8" Grid.ColumnSpan="10" Grid.Row="0" Grid.RowSpan="3" Name="OK" Margin="3"
                           Click="OK_Click" Text="Generate them! (and go to next)" LargeIcon="/Images/generate32.gif">
                            <fluent:Button.ToolTip>
                                <fluent:ScreenTip Title="Generate (and go to next)" Text="Generate the selected items (using current selected values) and step to the next movie"/>
                            </fluent:Button.ToolTip>
                        </fluent:Button>
                    </Grid>

                    <fluent:Button Click="Done_Click" Margin="10 0 0 0" Name="Done" Text="I'm done here! (go to next)" LargeIcon="/Images/done32.png">
                        <fluent:Button.ToolTip>
                            <fluent:ScreenTip Title="I am done" Text="I am done here take me to the next movie"/>
                        </fluent:Button.ToolTip>
                    </fluent:Button>

                    <fluent:Button Click="Skip_Click" Text="Skip Movie" Margin="10 0 0 0" Name="Skip" LargeIcon="/Images/jump32.png">
                        <fluent:Button.ToolTip>
                            <fluent:ScreenTip Title="Skip Movie" Text="Skip processing current movie"/>
                        </fluent:Button.ToolTip>
                    </fluent:Button>

                    <fluent:Button Click="SkipFolder_Click" Text="Skip Current Folder" Name="SkipFolder" Margin="10 0 0 0" LargeIcon="/Images/skip32.png">
                        <fluent:Button.ToolTip>
                            <fluent:ScreenTip Title="Skip Folder" Text="Skip processing current folder"/>
                        </fluent:Button.ToolTip>
                    </fluent:Button>

                    <fluent:Button Name="ChangeQuery" Click="ChangeQuery_Click" Text="Adjust Keywords" Margin="10 0 0 0" LargeIcon="/images/search32.png">
                        <fluent:Button.ToolTip>
                            <fluent:ScreenTip Title="Adjust Keywords" Text="Adjust the keywords used for this query and resend it"/>
                        </fluent:Button.ToolTip>
                    </fluent:Button>

                    <fluent:Button Text=" Options " Click="Options_Click" LargeIcon="/images/options32.png" Margin="10 0 0 0">
                        <fluent:Button.ToolTip>
                            <fluent:ScreenTip Title="Options" Text="Customize ThumbGen's parameters"/>
                        </fluent:Button.ToolTip>
                    </fluent:Button>

                    <fluent:Button Name="Abort" Click="Abort_Click" Text="Abort Processing" Margin="10 0 0 0" LargeIcon="/images/stop32.png">
                        <fluent:Button.ToolTip>
                            <fluent:ScreenTip Title="Abort All" Text="Abort processing for all movies"/>
                        </fluent:Button.ToolTip>
                    </fluent:Button>

                </fluent:RibbonGroupBox>
            </fluent:RibbonTabItem>
        </fluent:Ribbon>
        <ad:DockingManager x:Name="DockManager" Grid.Row="1" DataContext="{Binding Source={x:Static local:FileManager.Configuration}, Path=Options}" Loaded="DockManager_Loaded"
                       Focusable="False">
            <ad:ResizingPanel Orientation="Horizontal" Focusable="False">
                <ad:ResizingPanel Orientation="Vertical" Focusable="False">
                    <ad:ResizingPanel Orientation="Horizontal" Focusable="False">
                        <ad:DocumentPane Focusable="False">
                            <ad:DockableContent IsCloseable="False"  x:Name="dcSearchResults" Title="Search Results" Focusable="False">
                                <TreeView Name="ResultsTree" ToolTip="Select a result item to see its image and details"
                          SelectedItemChanged="ResultsTree_SelectedItemChanged" Margin="5" ItemsSource="{Binding}">
                                </TreeView>
                            </ad:DockableContent>
                        </ad:DocumentPane>
                        <ad:DockablePane ad:ResizingPanel.ResizeWidth="210" Focusable="False">
                            <ad:DockableContent IsCloseable="False"  x:Name="dcCover" Title="Cover" Icon="/Images/image.png" Focusable="False">
                                <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Focusable="False">
                                    <Grid MinWidth="200">
                                        <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" x:Name="CoverHintBox">
                      <Run>Choose an image from</Run>
                      <LineBreak/>
                      <Run>the Search Results tree</Run>
                                        </TextBlock>
                                        <ContentControl Width="128" Height="191" x:Name="LoadingControl" HorizontalAlignment="Center" VerticalAlignment="Top">
                                            <local:LoadingScreen CustomOpacity="1" CustomMessage="Wait..."/>
                                        </ContentControl>
                                        <StackPanel Orientation="Vertical" x:Name="InfoPanel">
                                            <Border Width="126" Height="189" Margin="3" BorderBrush="Gray" BorderThickness="1" AllowDrop="False" >
                                                <Grid AllowDrop="False" x:Name="NewImageGrid">
                                                    <Canvas x:Name="NewImageCanvas">
                                                        <Rectangle Stroke="DarkGreen" StrokeThickness="1" Name="CurrentSizeMarker">
                                                            <Rectangle.StrokeDashArray>
                                                                <sys:Double>3</sys:Double>
                                                            </Rectangle.StrokeDashArray>
                                                        </Rectangle>
                                                        <Image HorizontalAlignment="Left" Margin="0" x:Name="newImage" VerticalAlignment="Top"
                PreviewMouseLeftButtonDown="Source_PreviewMouseLeftButtonDown" Cursor="ScrollAll"
                PreviewMouseMove="newImage_PreviewMouseMove" ToolTip="Drag me over the moviesheet to use me"/>
                                                        <TextBlock x:Name="Watermark" HorizontalAlignment="Left" VerticalAlignment="Top"
   Text="{Binding ElementName=WatermarkText,Path=Text}" Cursor="Hand"
   Visibility="{Binding ElementName=cbUseCaption,Path=IsChecked,Mode=OneWay,Converter={StaticResource BoolVisibilityConverter}}"
   FontFamily="{Binding ElementName=WatermarkFont,Path=SelectedItem,FallbackValue=Tahoma}"
   FontSize="{Binding ElementName=WatermarkFontSize,Path=Value,FallbackValue=16,StringFormat=\{0\}pt}"
                                       FontStyle="{Binding ElementName=cbItalic, Path=IsChecked,Converter={StaticResource Bool2StyleConverter}}"
                                       FontWeight="{Binding ElementName=cbBold, Path=IsChecked,Converter={StaticResource Bool2WeightConverter}}"
   local:DraggableExtender.CanDrag="True"
       Canvas.Left="{Binding WatermarkOptions.Position.Width}"
       Canvas.Top="{Binding WatermarkOptions.Position.Height}"/>
                                                        <Canvas.RenderTransform>
                                                            <ScaleTransform ScaleX="0.525" ScaleY="0.525"/>
                                                        </Canvas.RenderTransform>
                                                    </Canvas>
                                                </Grid>
                                            </Border>
                                            <TextBlock x:Name="newImageSize" HorizontalAlignment="Center" Margin="3"/>

                                            <StackPanel Margin="2" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
                                                <Button x:Name="GenerateThumbButton" VerticalAlignment="Center" Margin="2"
        Click="GenerateThumbButton_Click" ToolTip="Generate thumbnail from the selected image">
                                                    <StackPanel Orientation="Horizontal">
                                                        <Image Source="Images/image.png" Height="16" Cursor="Hand" SnapsToDevicePixels="True" VerticalAlignment="Center"/>
                                                        <TextBlock FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="2 0 0 0">
                              <Run>Generate</Run>
                                                        </TextBlock>
                                                    </StackPanel>
                                                </Button>

                                                <Button x:Name="UseCoverForMovieSheetButton" Margin="2" VerticalAlignment="Center"
Click="UseCoverForMovieSheetButton_Click" ToolTip="Use the current cover inside the moviesheet"
Visibility="{Binding Source={x:Static local:FileManager.EnableMovieSheets}, Converter={StaticResource BoolVisibilityConverter}}">
                                                    <Image Source="/images/done.png" VerticalAlignment="Center" Width="16" Height="16"/>
                                                </Button>

                                                <Button x:Name="LoadImageFromDiskButton" Margin="2" VerticalAlignment="Center"
Click="LoadImageFromDiskButton_Click" ToolTip="Load my cover from disk">
                                                    <Image Source="/images/open.png" VerticalAlignment="Center" Width="16" Height="16"/>
                                                </Button>

                                                <Button x:Name="SaveOriginalImageButton" Margin="2" VerticalAlignment="Center"
Click="SaveOriginalImageButton_Click" ToolTip="Save original cover to disk">
                                                    <Image Source="/images/save.png" VerticalAlignment="Center" Width="16" Height="16"/>
                                                </Button>

                                                <Button x:Name="PreviewCoverButton" Margin="2"
                                Click="PreviewCoverButton_Click" ToolTip="View original cover">
                                                    <Image Source="/images/view.png" VerticalAlignment="Center" Width="16" Height="16"/>
                                                </Button>
                                            </StackPanel>
                                            <!--<GroupBox Header="Batch processing" Name="grpBatchProcessing" Style="{StaticResource GroupBoxStyle}" Margin="2">-->
                                            <StackPanel Orientation="Vertical" HorizontalAlignment="Center" Margin="2" x:Name="grpBatchProcessing">
                                                <Button Margin="1" ToolTip="Choose the selected image as thumbnail for all movies in the current folder"
            MinWidth="75" Name="BatchApply" VerticalAlignment="Center" HorizontalAlignment="Center" Click="BatchApply_Click"
            Content="Choose it for all files in this folder..."/>
                                                <CheckBox x:Name="cbAutoSkipAfterBatch" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0 5 0 2"
            Content="When done skip to next movie">
                                                    <CheckBox.ToolTip>
                                                        <TextBlock>
                              <Run>If checked the program will jump automatically to the next movie after generating thumbnails </Run>
                              <LineBreak/>
                              <Run>(otherwise user must press 'Skip current folder')</Run>
                                                        </TextBlock>
                                                    </CheckBox.ToolTip>
                                                </CheckBox>
                                            </StackPanel>
                                            <!--</GroupBox>-->
                                        </StackPanel>
                                    </Grid>
                                </ScrollViewer>
                            </ad:DockableContent>
                        </ad:DockablePane>
                    </ad:ResizingPanel>

                    <ad:ResizingPanel Orientation="Horizontal" Focusable="False">
                        <ad:DockablePane Visibility="Visible" Focusable="False">
                            <ad:DockableContent  IsCloseable="False" x:Name="dcBackdrops" Title="Backdrops" Icon="/Images/backdrop.png" Focusable="False">
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="*"/>
                                    </Grid.RowDefinitions>
                                    <StackPanel Orientation="Horizontal" Margin="1" Grid.Row="0">
                                        <Button Margin="0" VerticalAlignment="Center" Click="LoadBackdropFromDisk_Click" ToolTip="Load my backdrop from disk" Visibility="Visible">
                                            <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="0">
                                                <Image Source="/images/open.png" VerticalAlignment="Center" Width="16" Height="16"/>
                                                <TextBlock FontWeight="Normal" Margin="5 0 0 0" VerticalAlignment="Center">Load backdrop from disk</TextBlock>
                                            </StackPanel>
                                        </Button>

                                        <Button x:Name="GetRandomBackdrop" VerticalAlignment="Center" Click="GetRandomBackdrop_Click" Margin="10 0 0 0">
                                            <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="0">
                                                <Image Source="/images/dice.png" Width="16" Height="16" VerticalAlignment="Center"/>
                                                <TextBlock Margin="5 0 0 0" VerticalAlignment="Center">Get random snapshot</TextBlock>
                                            </StackPanel>
                                        </Button>
                                        <TextBlock Text="or" Margin="5 0 5 0" VerticalAlignment="Center" FontSize="10" FontWeight="Bold"/>
                                        <Button x:Name="GetCustomSnapshotBackdrop" Margin="0 0 0 0" VerticalAlignment="Center" Click="GetCustomSnapshotBackdrop_Click">
                                            <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="0">
                                                <Image Source="/images/camera.png" Width="16" Height="16" VerticalAlignment="Center"/>
                                                <TextBlock FontWeight="Normal" Margin="5 0 0 0" VerticalAlignment="Center">Get snapshot...</TextBlock>
                                            </StackPanel>
                                        </Button>
                                    </StackPanel>

                                    <ListBox Grid.Row="1" Margin="1" Name="BackdropsBox" ToolTip="List of available backdrops" VerticalAlignment="Stretch" IsSynchronizedWithCurrentItem="True" Focusable="False"
                              SelectionMode="Single" ItemsSource="{Binding}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto"
                              VirtualizingStackPanel.IsVirtualizing="True">
                                        <ListBox.ItemsPanel>
                                            <ItemsPanelTemplate>
                                                <WrapPanel/>
                                            </ItemsPanelTemplate>
                                        </ListBox.ItemsPanel>
                                        <ListBox.ItemTemplate>
                                            <DataTemplate>
                                                <StackPanel Orientation="Vertical">
                                                    <Image Source="{Binding ThumbUrl,Converter={StaticResource ImageFixConverter}}"
                 Height="150" Width="266" HorizontalAlignment="Center" Margin="3"
                 Stretch="Fill" Cursor="ScrollAll"
                 ToolTip="Drag me over the moviesheet to use me"
                 PreviewMouseLeftButtonDown="Source_PreviewMouseLeftButtonDown"
                 PreviewMouseMove="Image_PreviewMouseMove"/>
                                                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                                                        <TextBlock VerticalAlignment="Center" Margin="0 0 10 0" ToolTip="Original image size">
                                                            <TextBlock.Text>
                                                                <MultiBinding StringFormat="{} {0} x {1}">
                                                                    <Binding Path="Width" />
                                                                    <Binding Path="Height" />
                                                                </MultiBinding>
                                                            </TextBlock.Text>
                                                        </TextBlock>
                                                        <Button x:Name="UseBackdropForFanart1" Tag="{Binding}" Margin="2" VerticalAlignment="Center"
                            ToolTip="Use the current backdrop inside the moviesheet as Fanart 1" Click="UseBackdropForFanart1_Click"
                            Visibility="{Binding Source={x:Static local:FileManager.EnableMovieSheets}, Converter={StaticResource BoolVisibilityConverter}}">
                                                            <Image Source="/images/fanart1.png" VerticalAlignment="Center" Width="16" Height="16"/>
                                                        </Button>
                                                        <Button x:Name="UseBackdropForFanart2" Tag="{Binding}" Margin="2" VerticalAlignment="Center"
                            ToolTip="Use the current backdrop inside the moviesheet as Fanart 2" Click="UseBackdropForFanart2_Click"
                            Visibility="{Binding Source={x:Static local:FileManager.EnableMovieSheets}, Converter={StaticResource BoolVisibilityConverter}}">
                                                            <Image Source="/images/fanart2.png" VerticalAlignment="Center" Width="16" Height="16"/>
                                                        </Button>
                                                        <Button x:Name="UseBackdropForFanart3" Tag="{Binding}" Margin="2" VerticalAlignment="Center"
                            ToolTip="Use the current backdrop inside the moviesheet as Fanart 3" Click="UseBackdropForFanart3_Click"
                            Visibility="{Binding Source={x:Static local:FileManager.EnableMovieSheets}, Converter={StaticResource BoolVisibilityConverter}}">
                                                            <Image Source="/images/fanart3.png" VerticalAlignment="Center" Width="16" Height="16"/>
                                                        </Button>

                                                        <Button x:Name="UseBackdropForMovieSheetButton" Tag="{Binding}" Margin="2" VerticalAlignment="Center"
                            Click="UseBackdropForMovieSheetButton_Click" ToolTip="Use the current backdrop inside the moviesheet"
                            Visibility="{Binding Source={x:Static local:FileManager.EnableMovieSheets}, Converter={StaticResource BoolVisibilityConverter}}">
                                                            <Image Source="/images/done.png" VerticalAlignment="Center" Width="16" Height="16"/>
                                                        </Button>

                                                        <Button x:Name="PreviewBackdropButton" Tag="{Binding}" Margin="2"
                            Click="PreviewBackdropButton_Click" ToolTip="View original backdrop">
                                                            <Image Source="/images/view.png" VerticalAlignment="Center" Width="16" Height="16"/>
                                                        </Button>
                                                        <Button x:Name="SaveBackdropButton" Tag="{Binding}" Margin="2"
                            Click="SaveBackdropButton_Click" ToolTip="Save original backdrop">
                                                            <Image Source="/images/save.png" VerticalAlignment="Center" Width="16" Height="16"/>
                                                        </Button>
                                                    </StackPanel>
                                                </StackPanel>
                                            </DataTemplate>
                                        </ListBox.ItemTemplate>
                                        <ListBox.ItemContainerStyle>
                                            <Style TargetType="{x:Type ListBoxItem}">
                                                <Style.Triggers>
                                                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsSelected}" Value="True">
                                                        <Setter Property="IsSelected" Value="True"/>
                                                    </DataTrigger>
                                                </Style.Triggers>
                                                <!--<Setter Property="Template">
                          <Setter.Value>
                            <ControlTemplate TargetType="ListBoxItem">
                              <ContentPresenter />
                            </ControlTemplate>
                          </Setter.Value>
                        </Setter>-->
                                                <Setter Property="VerticalContentAlignment" Value="Stretch"/>
                                                <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                                            </Style>
                                        </ListBox.ItemContainerStyle>
                                    </ListBox>
                                </Grid>

                            </ad:DockableContent>
                            <ad:DockableContent  IsCloseable="False" x:Name="dcExistingItems" Title="Existing Items" Icon="/Images/backdrop.png" Focusable="False">
                                <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Focusable="False">
                                    <StackPanel Orientation="Horizontal">
                                        <GroupBox Header="Thumbnail" Style="{StaticResource GroupBoxStyle}" Margin="3">
                                            <Grid>
                                                <StackPanel Orientation="Vertical">
                                                    <Border Width="126" Height="189" BorderBrush="Gray" BorderThickness="1" Margin="5">
                                                        <Grid>
                                                            <Canvas x:Name="ExistingImageCanvas">
                                                                <Image HorizontalAlignment="Left"  VerticalAlignment="Top" Margin="0" Name="existingimage" Stretch="Uniform" SnapsToDevicePixels="True" Width="126" Height="189"/>
                                                                <!--<Canvas.RenderTransform>
                                                    <ScaleTransform ScaleX="0.525" ScaleY="0.525"/>
                                                </Canvas.RenderTransform>-->
                                                            </Canvas>
                                                        </Grid>
                                                    </Border>
                                                    <TextBlock x:Name="existingImageSize" HorizontalAlignment="Center" Margin="5"/>
                                                    <StackPanel Margin="3" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center">
                                                        <Button Margin="2" VerticalAlignment="Center" Click="UseExistingImageAsCoverForMovieSheet_Click"
                ToolTip="Use the existing thumbnail as cover inside the moviesheet"
                Visibility="{Binding Source={x:Static local:FileManager.EnableMovieSheets}, Converter={StaticResource BoolVisibilityConverter}}">
                                                            <Image Source="/images/done.png" VerticalAlignment="Center" Width="16" Height="16"/>
                                                        </Button>
                                                    </StackPanel>
                                                </StackPanel>
                                            </Grid>
                                        </GroupBox>
                                        <GroupBox Header="Current moviesheet(s)" Style="{StaticResource GroupBoxStyle}" Margin="3" >
                                            <Grid>
                                                <Grid.RowDefinitions>
                                                    <RowDefinition Height="Auto"/>
                                                    <RowDefinition Height="*"/>
                                                    <RowDefinition Height="Auto"/>
                                                </Grid.RowDefinitions>
                                                <TabControl Grid.Row="1" x:Name="CurrentSheetsTabControl" TabStripPlacement="Top">
                                                    <TabItem>
                                                        <TabItem.HeaderTemplate>
                                                            <DataTemplate>
                                                                <StackPanel Orientation="Horizontal">
                                                                    <Image Source="/images/backdrop.png" VerticalAlignment="Center" Width="16" Height="16"/>
                                                                    <TextBlock Margin="5 0 0 0" VerticalAlignment="Center" Text="Main sheet"/>
                                                                </StackPanel>
                                                            </DataTemplate>
                                                        </TabItem.HeaderTemplate>
                                                        <Border Grid.Row="1" BorderBrush="White" BorderThickness="1" Height="180" Width="320" VerticalAlignment="Center" HorizontalAlignment="Center" AllowDrop="False" >
                                                            <Image x:Name="ExistingMovieSheetSmallImage" Stretch="Uniform"/>
                                                        </Border>
                                                    </TabItem>
                                                    <TabItem Visibility="{Binding Source={x:Static local:FileManager.Configuration},Path=Options.AutogenerateMoviesheetForFolder,Converter={StaticResource BoolVisibilityConverter}}">
                                                        <TabItem.HeaderTemplate>
                                                            <DataTemplate>
                                                                <StackPanel Orientation="Horizontal">
                                                                    <Image Source="/images/moviesheet_folder.png" VerticalAlignment="Center" Width="16" Height="16"/>
                                                                    <TextBlock Margin="5 0 0 0" VerticalAlignment="Center" Text="Extra sheet"/>
                                                                </StackPanel>
                                                            </DataTemplate>
                                                        </TabItem.HeaderTemplate>
                                                        <Border Grid.Row="1" BorderBrush="White" BorderThickness="1" Height="180" Width="320" VerticalAlignment="Center" HorizontalAlignment="Center" AllowDrop="False" >
                                                            <Image x:Name="ExistingExtraMovieSheetSmallImage" Stretch="Uniform"/>
                                                        </Border>
                                                    </TabItem>
                                                    <TabItem>
                                                        <TabItem.HeaderTemplate>
                                                            <DataTemplate>
                                                                <StackPanel Orientation="Horizontal">
                                                                    <Image Source="/images/moviesheet_folder.png" VerticalAlignment="Center" Width="16" Height="16"/>
                                                                    <TextBlock Margin="5 0 0 0" VerticalAlignment="Center" Text="Spare sheet"/>
                                                                </StackPanel>
                                                            </DataTemplate>
                                                        </TabItem.HeaderTemplate>
                                                        <Border Grid.Row="1" BorderBrush="White" BorderThickness="1" Height="180" Width="320" VerticalAlignment="Center" HorizontalAlignment="Center" AllowDrop="False" >
                                                            <Image x:Name="ExistingParentFolderMovieSheetSmallImage" Stretch="Uniform"/>
                                                        </Border>
                                                    </TabItem>
                                                </TabControl>
                                                <StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Right" Grid.Row="2" >
                                                    <Button VerticalAlignment="Center" Click="RefreshExistingMovieSheetButton_Click" ToolTip="Refresh the moviesheet preview">
                                                        <Image Source="/images/refresh.png" Width="16" Height="16" VerticalAlignment="Center"/>
                                                    </Button>
                                                    <Button Margin="2" Click="PreviewExistingMovieSheetButton_Click"
              ToolTip="Preview full moviesheet" VerticalAlignment="Center">
                                                        <Image Source="/images/view.png" VerticalAlignment="Center" Width="16" Height="16"/>
                                                    </Button>
                                                </StackPanel>
                                            </Grid>
                                        </GroupBox>
                                    </StackPanel>
                                </ScrollViewer>
                            </ad:DockableContent>
                            <ad:DockableContent IsCloseable="False" x:Name="dcThumbnail" Title="Thumbnail" Icon="/Images/image.png" Focusable="False">
                                <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Focusable="False">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="Auto"/>
                                        </Grid.ColumnDefinitions>
                                        <GroupBox Grid.Column="0" Header="Thumbnail Properties" Name="grpThumbnailProps" Style="{StaticResource GroupBoxStyle}" Margin="3">
                                            <Grid Margin="1">
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="Auto"/>
                                                    <ColumnDefinition Width="Auto"/>
                                                </Grid.ColumnDefinitions>
                                                <Grid.RowDefinitions>
                                                    <RowDefinition Height="Auto"/>
                                                    <RowDefinition Height="Auto"/>
                                                    <RowDefinition Height="Auto"/>
                                                    <RowDefinition Height="Auto"/>
                                                </Grid.RowDefinitions>
                                                <TextBlock Grid.Column="0" Grid.Row="0" Text="Size:" VerticalAlignment="Center" Margin="3"/>
                                                <ComboBox Grid.Column="1" Grid.Row="0" SelectionChanged="comboThumbSize_SelectionChanged"
              Margin="3" HorizontalAlignment="Right"
              Name="comboThumbSize" VerticalAlignment="Center" Width="90" >
                                                    <ComboBox.Items>
                                                        <ComboBoxItem Content="120 x 160">
                                                            <ComboBoxItem.Tag>
                                                                <Size Width="120" Height="160"/>
                                                            </ComboBoxItem.Tag>
                                                        </ComboBoxItem>
                                                        <ComboBoxItem Content="120 x 180" Foreground="Navy">
                                                            <ComboBoxItem.Tag>
                                                                <Size Width="120" Height="180"/>
                                                            </ComboBoxItem.Tag>
                                                        </ComboBoxItem>
                                                        <ComboBoxItem Content="150 x 200">
                                                            <ComboBoxItem.Tag>
                                                                <Size Width="150" Height="200"/>
                                                            </ComboBoxItem.Tag>
                                                        </ComboBoxItem>
                                                        <ComboBoxItem Content="160 x 240">
                                                            <ComboBoxItem.Tag>
                                                                <Size Width="160" Height="240"/>
                                                            </ComboBoxItem.Tag>
                                                        </ComboBoxItem>
                                                        <ComboBoxItem Content="162 x 230">
                                                            <ComboBoxItem.Tag>
                                                                <Size Width="162" Height="230"/>
                                                            </ComboBoxItem.Tag>
                                                        </ComboBoxItem>
                                                        <ComboBoxItem Content="163 x 245">
                                                            <ComboBoxItem.Tag>
                                                                <Size Width="163" Height="245"/>
                                                            </ComboBoxItem.Tag>
                                                        </ComboBoxItem>
                                                        <ComboBoxItem Content="180 x 240">
                                                            <ComboBoxItem.Tag>
                                                                <Size Width="180" Height="240"/>
                                                            </ComboBoxItem.Tag>
                                                        </ComboBoxItem>
                                                        <ComboBoxItem Content="192 x 230">
                                                            <ComboBoxItem.Tag>
                                                                <Size Width="192" Height="230"/>
                                                            </ComboBoxItem.Tag>
                                                        </ComboBoxItem>
                                                        <ComboBoxItem Content="200 x 300" Foreground="Navy">
                                                            <ComboBoxItem.Tag>
                                                                <Size Width="200" Height="300"/>
                                                            </ComboBoxItem.Tag>
                                                        </ComboBoxItem>
                                                        <ComboBoxItem Content="225 x 300">
                                                            <ComboBoxItem.Tag>
                                                                <Size Width="225" Height="300"/>
                                                            </ComboBoxItem.Tag>
                                                        </ComboBoxItem>
                                                        <ComboBoxItem Content="240 x 360" Foreground="Navy">
                                                            <ComboBoxItem.Tag>
                                                                <Size Width="240" Height="360"/>
                                                            </ComboBoxItem.Tag>
                                                        </ComboBoxItem>
                                                    </ComboBox.Items>
                                                </ComboBox>
                                                <TextBlock Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" Margin="5 0 5 0"
               FontSize="9" Foreground="Navy" Text="(blue = supported by original firmware)"
               HorizontalAlignment="Left" VerticalAlignment="Center"/>
                                                <TextBlock Grid.Column="0" Grid.Row="2" Text="Aspect Ratio:" VerticalAlignment="Center" Margin="5"/>
                                                <ComboBox Grid.Column="1" Grid.Row="2" SelectionChanged="comboImageStretch_SelectionChanged"
              HorizontalAlignment="Right" Name="comboImageStretch" VerticalAlignment="Center" Width="90"
              Margin="5">
                                                    <ComboBox.Items>
                                                        <ComboBoxItem>Keep</ComboBoxItem>
                                                        <ComboBoxItem>Ignore</ComboBoxItem>
                                                    </ComboBox.Items>
                                                </ComboBox>
                                            </Grid>
                                        </GroupBox>
                                        <GroupBox Grid.Column="2" Header="Extra Thumbnail Tools" Name="grpFolderJPGTools" Style="{StaticResource GroupBoxStyle}" Margin="3">
                                            <StackPanel Orientation="Horizontal">
                                                <Border BorderBrush="Gray" BorderThickness="0.5" Margin="3">
                                                    <StackPanel Orientation="Vertical" Margin="5" HorizontalAlignment="Center">
                                                        <TextBlock HorizontalAlignment="Center">Create extra thumb for:</TextBlock>
                                                        <TextBlock HorizontalAlignment="Center" x:Name="ParentMovieFolderBlock" FontWeight="Bold"></TextBlock>
                                                        <TextBlock HorizontalAlignment="Center">(parent of the current folder)</TextBlock>
                                                        <Button Margin="0 5 0 0"  x:Name="ChooseSeriesThumb" HorizontalAlignment="Center"
                ToolTip="Create a thumbnail file in the folder displayed above using the currently selected image"
                Click="ChooseSeriesThumb_Click">Generate folder thumb</Button>
                                                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
                                                            <TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10">
                                <Run>Current extra thumb</Run>
                                <LineBreak/>
                                <Run>image is:</Run>
                                                            </TextBlock>
                                                            <Image HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10" Width="50" Height="75" x:Name="FolderImage"/>
                                                        </StackPanel>
                                                    </StackPanel>
                                                </Border>
                                                <Border BorderBrush="Gray" BorderThickness="0.5" Margin="3">
                                                    <StackPanel Orientation="Vertical" Margin="5" HorizontalAlignment="Center">
                                                        <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center">Create extra thumb for:</TextBlock>
                                                        <TextBlock HorizontalAlignment="Center" x:Name="CurrentFolderBlock" FontWeight="Bold"></TextBlock>
                                                        <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center">(the current folder)</TextBlock>
                                                        <Button Margin="0 5 0 0"  x:Name="ChooseCurrentFolderThumb" HorizontalAlignment="Center"
                ToolTip="Create a thumbnail file in the current folder using the currently selected image"
                Click="ChooseCurrentFolderThumb_Click">Generate folder thumb</Button>
                                                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
                                                            <TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10">
                                <Run>Current extra thumb</Run>
                                <LineBreak/>
                                <Run>image is:</Run>
                                                            </TextBlock>
                                                            <Image HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10" Width="50" Height="75" x:Name="CurrentFolderImage"/>
                                                        </StackPanel>
                                                    </StackPanel>
                                                </Border>
                                            </StackPanel>
                                        </GroupBox>
                                    </Grid>
                                </ScrollViewer>
                            </ad:DockableContent>
                            <ad:DockableContent IsCloseable="False" x:Name="dcCustomText" Title="Custom Text" Icon="/Images/document_edit.png">
                                <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Focusable="False">
                                    <Grid x:Name="EpisodeCaptionEditorGrid" Margin="5">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="90"/>
                                            <ColumnDefinition Width="130"/>
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="25"/>
                                            <RowDefinition Height="25"/>
                                            <RowDefinition Height="25"/>
                                            <RowDefinition Height="25"/>
                                            <RowDefinition Height="25"/>
                                            <RowDefinition Height="25"/>
                                            <RowDefinition Height="25"/>
                                            <RowDefinition Height="25"/>
                                        </Grid.RowDefinitions>
                                        <TextBlock Grid.Column="0" Grid.Row="0" Text="Font:" Margin="2" VerticalAlignment="Center"/>
                                        <ComboBox Grid.Column="1" Grid.Row="0" x:Name="WatermarkFont" Margin="2"
              VerticalAlignment="Center" IsSynchronizedWithCurrentItem="True"
              ItemsSource="{x:Static Fonts.SystemFontFamilies}"
              SelectedItem="{Binding WatermarkOptions.FontFamily, Mode=TwoWay}"
              DataContextChanged="WatermarkFont_DataContextChanged"/>
                                        <TextBlock Grid.Column="0" Grid.Row="1" Text="Font size:" Margin="2" VerticalAlignment="Center"/>
                                        <Slider Grid.Column="1" Grid.Row="1" x:Name="WatermarkFontSize" Minimum="5" Maximum="100"
            Width="85" SmallChange="1" Margin="2" VerticalAlignment="Center"
            ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=Value}"
            Value="{Binding WatermarkOptions.FontSize}"/>
                                        <TextBlock Grid.Column="0" Grid.Row="2" Text="Font color:" Margin="2" VerticalAlignment="Center"/>
                                        <ComboBox Grid.Column="1" Grid.Row="2" x:Name="WatermarkColor" Margin="2" VerticalAlignment="Center"
              IsSynchronizedWithCurrentItem="True" SelectionChanged="WatermarkColor_SelectionChanged"
              SelectedIndex="{Binding WatermarkOptions.FontColorIndex}">
                                            <ComboBox.ItemTemplate>
                                                <DataTemplate>
                                                    <StackPanel Orientation="Horizontal">
                                                        <Rectangle Margin="1 1 3 1" Width="10" Fill="{Binding Name}" />
                                                        <TextBlock Text="{Binding Name}" />
                                                    </StackPanel>
                                                </DataTemplate>
                                            </ComboBox.ItemTemplate>
                                        </ComboBox>
                                        <StackPanel Orientation="Horizontal" Grid.Column="0" Grid.ColumnSpan="3" Grid.Row="3" >
                                            <CheckBox x:Name="cbBold" Margin="5" IsChecked="{Binding WatermarkOptions.Bold}" Content="Bold"/>
                                            <CheckBox x:Name="cbItalic" IsChecked="{Binding WatermarkOptions.Italic}" Content="Italic" Margin="10 5 5 5"/>
                                        </StackPanel>
                                        <TextBlock Grid.Column="0" Grid.Row="4" Text="Position:" Margin="2" VerticalAlignment="Center"/>
                                        <TextBlock Grid.Column="1" Grid.Row="4" VerticalAlignment="Center" HorizontalAlignment="Center"
               Text="drag text over image" Margin="2"/>
                                        <TextBlock Grid.Column="0" Grid.Row="5" Text="Custom Text:" Margin="2" VerticalAlignment="Center"/>
                                        <TextBox Grid.Column="1" Grid.Row="5"  x:Name="WatermarkText" MinWidth="80"
                 Text="{Binding WatermarkOptions.Text}" Margin="2" VerticalAlignment="Center"/>
                                        <CheckBox Grid.Column="0" Grid.ColumnSpan="3" Grid.Row="6" x:Name="cbUseCaption" FontWeight="Bold" Margin="5"
              HorizontalAlignment="Center" Click="cbUseCaption_Click"
              IsChecked="{Binding AddWatermark}">Add custom text to the thumbnail</CheckBox>
                                    </Grid>
                                </ScrollViewer>
                            </ad:DockableContent>
                            <ad:DockableContent IsCloseable="False" x:Name="dcOwnSnapshots" Title="Own Movie Snapshots" Icon="/Images/snapshot.png" Focusable="False">
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="*"/>
                                        <RowDefinition Height="Auto"/>
                                    </Grid.RowDefinitions>

                                    <StackPanel Orientation="Horizontal" Margin="5" >
                                        <Button x:Name="GetRandomSnapshotsMix" VerticalAlignment="Center" Click="GetRandomSnapshotsMix_Click" IsEnabled="{Binding IsMTNPathSpecified}">
                                            <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="2">
                                                <Image Source="/images/dice.png" Width="16" Height="16" VerticalAlignment="Center"/>
                                                <TextBlock Margin="5 0 0 0" VerticalAlignment="Center">Get random thumb</TextBlock>
                                            </StackPanel>
                                        </Button>
                                        <TextBlock Text="or" Margin="5 0 5 0" VerticalAlignment="Center" FontSize="10" FontWeight="Bold"/>
                                        <Button x:Name="VideoSnapButton" Margin="0 0 0 0" VerticalAlignment="Center" Click="VideoSnapButton_Click">
                                            <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="2">
                                                <Image Source="/images/camera.png" Width="16" Height="16" VerticalAlignment="Center"/>
                                                <TextBlock FontWeight="Normal" Margin="5 0 0 0" VerticalAlignment="Center">Take snapshots...</TextBlock>
                                            </StackPanel>
                                        </Button>
                                        <TextBlock FontWeight="Normal" Margin="10 0 0 0" VerticalAlignment="Center" FontSize="10">
                          <Run>enter the snapshots IDs that you</Run>
                          <LineBreak/>
                          <Run>want to have in the thumbnail</Run>
                          <LineBreak/>
                          <Run>(any order but comma separated)</Run>
                                        </TextBlock>
                                        <TextBox x:Name="SnapshotsIndexes" Margin="5 0 0 0" Text="0" Width="50" LostKeyboardFocus="SnapshotsIndexes_LostKeyboardFocus" VerticalAlignment="Center"/>
                                        <TextBlock FontWeight="Normal" Margin="10 0 10 0" FontSize="10" VerticalAlignment="Center">then</TextBlock>
                                        <Button x:Name="RefreshOwnSnapshotMix" VerticalAlignment="Center" Click="RefreshOwnSnapshotMix_Click">
                                            <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="2">
                                                <Image Source="/images/refresh.png" Width="16" Height="16" VerticalAlignment="Center"/>
                                                <TextBlock Margin="5 0 0 0" VerticalAlignment="Center">Refresh</TextBlock>
                                            </StackPanel>
                                        </Button>
                                    </StackPanel>
                                    <ListBox Grid.Row="1" Margin="5" Name="SnapshotsBox" ToolTip="Choose at least one snapshot from the list" VerticalAlignment="Center"
                      IsSynchronizedWithCurrentItem="True" Focusable="False" SelectionMode="Multiple" ItemsSource="{Binding}" FocusVisualStyle="{x:Null}"
                      ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto">
                                        <ListBox.ItemsPanel>
                                            <ItemsPanelTemplate>
                                                <WrapPanel/>
                                            </ItemsPanelTemplate>
                                        </ListBox.ItemsPanel>
                                        <ListBox.ItemTemplate>
                                            <HierarchicalDataTemplate>
                                                <StackPanel Orientation="Vertical">
                                                    <Image Source="{Binding ImageUrl, Converter={StaticResource ImageFixConverter}}" Width="90" Height="135" HorizontalAlignment="Center" Margin="5"/>
                                                    <TextBlock HorizontalAlignment="Center" MinWidth="20" Text="{Binding Index}" Margin="3"/>
                                                </StackPanel>
                                            </HierarchicalDataTemplate>
                                        </ListBox.ItemTemplate>
                                        <ListBox.ItemContainerStyle>
                                            <Style TargetType="{x:Type ListBoxItem}">
                                                <Style.Triggers>
                                                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsSelected}" Value="True">
                                                        <Setter Property="IsSelected" Value="True"/>
                                                    </DataTrigger>
                                                </Style.Triggers>
                                                <!--Setter Property="Template">
                              <Setter.Value>
                                <ControlTemplate TargetType="ListBoxItem">
                                  <ContentPresenter />
                                </ControlTemplate>
                              </Setter.Value>
                            </Setter>-->
                                                <Setter Property="VerticalContentAlignment" Value="Stretch"/>
                                                <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                                            </Style>
                                        </ListBox.ItemContainerStyle>
                                    </ListBox>
                                    <TextBlock Grid.Row="2">
                        <Run>This feature requires Windows Media Player v10+ and proper codecs like: </Run>
                        <Hyperlink NavigateUri="http://www.free-codecs.com/download/Haali_Matroska_Splitter.htm" local:HyperlinkController.NavigatesToUrl="True">Haali Splitter</Hyperlink>
                        <Run>, </Run>
                        <Hyperlink NavigateUri="http://www.ffdshow.info" local:HyperlinkController.NavigatesToUrl="True">ffdshow</Hyperlink>
                        <Run> and </Run>
                        <Hyperlink NavigateUri="http://www.free-codecs.com/3ivx_download.htm" local:HyperlinkController.NavigatesToUrl="True">3ivx Codec</Hyperlink>
                        <Run>.</Run>
                                    </TextBlock>
                                </Grid>
                            </ad:DockableContent>
                            <ad:DockableContent IsCloseable="False" x:Name="dcExternalSubs" Title="External Subtitles" Icon="/Images/OpenSubtitlesFavIcon.gif" Focusable="False">
                                <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Focusable="False">
                                    <StackPanel Orientation="Horizontal">
                                        <GroupBox Header="Subtitles in the current folder" Style="{StaticResource GroupBoxStyle}" Margin="3">
                                            <StackPanel Orientation="Vertical" HorizontalAlignment="Center">
                                                <StackPanel Orientation="Horizontal">
                                                    <!--<TextBlock Text="Subs in current folder:" Margin="5" VerticalAlignment="Center"/>-->
                                                    <ComboBox x:Name="SubsCombo" MinWidth="120" MaxWidth="200" IsSynchronizedWithCurrentItem="True" Height="23" Foreground="Black"
                                ItemsSource="{Binding}" SelectionChanged="SubsCombo_SelectionChanged">
                                                        <ComboBox.Resources>
                                                            <Style TargetType="ComboBoxItem">
                                                                <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}"/>
                                                            </Style>
                                                        </ComboBox.Resources>
                                                        <ComboBox.ItemTemplate>
                                                            <DataTemplate>
                                                                <TextBlock Margin="2" Text="{Binding FileInfo.Name}"
                       ToolTip="{Binding FileInfo.Name}"/>
                                                            </DataTemplate>
                                                        </ComboBox.ItemTemplate>
                                                    </ComboBox>
                                                    <Button x:Name="SubsRefresh" Click="SubsRefresh_Click" Margin="5">
                                                        <Image Source="/images/refresh.png" Width="16" Height="16" ToolTip="Refresh list of subtitles from current folder"/>
                                                    </Button>
                                                </StackPanel>
                                                <StackPanel Orientation="Vertical" HorizontalAlignment="Center">
                                                    <Button x:Name="SubDelete" Content="Delete selected subtitle" Margin="5" Click="SubDelete_Click" Width="150"/>
                                                    <Button x:Name="SubRename" Content="Rename selected as movie" Click="SubRename_Click" Margin="5" Width="150"/>
                                                    <Button x:Name="TestSubsButton" Click="TestSubsButton_Click" Content="Test current subtitle" HorizontalAlignment="Center"
                              Margin="5" VerticalAlignment="Center" Width="150"/>
                                                </StackPanel>
                                            </StackPanel>
                                        </GroupBox>
                                        <GroupBox Header="Get new subtitles" Style="{StaticResource GroupBoxStyle}" Margin="3">
                                            <StackPanel Orientation="Vertical">
                                                <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                                                    <TextBlock Text="CDs:" Margin="5" VerticalAlignment="Center" Foreground="Black"/>
                                                    <ComboBox x:Name="CDsCombo" MinWidth="60" IsSynchronizedWithCurrentItem="True" Margin="5" VerticalAlignment="Center">
                                                        <ComboBox.Items>
                                                            <ComboBoxItem Content="1 CD" Tag="1" IsSelected="True"/>
                                                            <ComboBoxItem Content="2 CD" Tag="2"/>
                                                            <ComboBoxItem Content="3 CD" Tag="3"/>
                                                            <ComboBoxItem Content="4 CD" Tag="4"/>
                                                        </ComboBox.Items>
                                                    </ComboBox>
                                                    <TextBlock Text="Language:" Margin="5" VerticalAlignment="Center" Foreground="Black"/>
                                                    <ComboBox x:Name="LanguagesCombo" MinWidth="70" IsSynchronizedWithCurrentItem="True" Margin="5" VerticalAlignment="Center">
                                                        <ComboBox.Items>
                                                            <ComboBoxItem Tag="all" IsSelected="True">ALL</ComboBoxItem>
                                                            <ComboBoxItem Tag="alb">Albanian</ComboBoxItem>
                                                            <ComboBoxItem Tag="ara">Arabic</ComboBoxItem>
                                                            <ComboBoxItem Tag="arm">Armenian</ComboBoxItem>
                                                            <ComboBoxItem Tag="bos">Bosnian</ComboBoxItem>
                                                            <ComboBoxItem Tag="bul">Bulgarian</ComboBoxItem>
                                                            <ComboBoxItem Tag="cat">Catalan</ComboBoxItem>
                                                            <ComboBoxItem Tag="chi">Chinese</ComboBoxItem>
                                                            <ComboBoxItem Tag="hrv">Croatian</ComboBoxItem>
                                                            <ComboBoxItem Tag="cze">Czech</ComboBoxItem>
                                                            <ComboBoxItem Tag="dan">Danish</ComboBoxItem>
                                                            <ComboBoxItem Tag="dut">Dutch</ComboBoxItem>
                                                            <ComboBoxItem Tag="eng">English</ComboBoxItem>
                                                            <ComboBoxItem Tag="epo">Esperanto</ComboBoxItem>
                                                            <ComboBoxItem Tag="est">Estonian</ComboBoxItem>
                                                            <ComboBoxItem Tag="per">Farsi</ComboBoxItem>
                                                            <ComboBoxItem Tag="fin">Finnish</ComboBoxItem>
                                                            <ComboBoxItem Tag="fre">French</ComboBoxItem>
                                                            <ComboBoxItem Tag="glg">Galician</ComboBoxItem>
                                                            <ComboBoxItem Tag="geo">Georgian</ComboBoxItem>
                                                            <ComboBoxItem Tag="ger">German</ComboBoxItem>
                                                            <ComboBoxItem Tag="ell">Greek</ComboBoxItem>
                                                            <ComboBoxItem Tag="heb">Hebrew</ComboBoxItem>
                                                            <ComboBoxItem Tag="hin">Hindi</ComboBoxItem>
                                                            <ComboBoxItem Tag="hun">Hungarian</ComboBoxItem>
                                                            <ComboBoxItem Tag="ice">Icelandic</ComboBoxItem>
                                                            <ComboBoxItem Tag="ind">Indonesian</ComboBoxItem>
                                                            <ComboBoxItem Tag="ita">Italian</ComboBoxItem>
                                                            <ComboBoxItem Tag="jpn">Japanese</ComboBoxItem>
                                                            <ComboBoxItem Tag="kaz">Kazakh</ComboBoxItem>
                                                            <ComboBoxItem Tag="kor">Korean</ComboBoxItem>
                                                            <ComboBoxItem Tag="lav">Latvian</ComboBoxItem>
                                                            <ComboBoxItem Tag="lit">Lithuanian</ComboBoxItem>
                                                            <ComboBoxItem Tag="ltz">Luxembourgish</ComboBoxItem>
                                                            <ComboBoxItem Tag="mac">Macedonian</ComboBoxItem>
                                                            <ComboBoxItem Tag="may">Malay</ComboBoxItem>
                                                            <ComboBoxItem Tag="nor">Norwegian</ComboBoxItem>
                                                            <ComboBoxItem Tag="oci">Occitan</ComboBoxItem>
                                                            <ComboBoxItem Tag="pol">Polish</ComboBoxItem>
                                                            <ComboBoxItem Tag="por">Portuguese</ComboBoxItem>
                                                            <ComboBoxItem Tag="pob">Portuguese-BR</ComboBoxItem>
                                                            <ComboBoxItem Tag="rum">Romanian</ComboBoxItem>
                                                            <ComboBoxItem Tag="rus">Russian</ComboBoxItem>
                                                            <ComboBoxItem Tag="scc">Serbian</ComboBoxItem>
                                                            <ComboBoxItem Tag="sin">Sinhalese</ComboBoxItem>
                                                            <ComboBoxItem Tag="slo">Slovak</ComboBoxItem>
                                                            <ComboBoxItem Tag="slv">Slovenian</ComboBoxItem>
                                                            <ComboBoxItem Tag="spa">Spanish</ComboBoxItem>
                                                            <ComboBoxItem Tag="swe">Swedish</ComboBoxItem>
                                                            <ComboBoxItem Tag="syr">Syriac</ComboBoxItem>
                                                            <ComboBoxItem Tag="tgl">Tagalog</ComboBoxItem>
                                                            <ComboBoxItem Tag="tha">Thai</ComboBoxItem>
                                                            <ComboBoxItem Tag="tur">Turkish</ComboBoxItem>
                                                            <ComboBoxItem Tag="ukr">Ukrainian</ComboBoxItem>
                                                            <ComboBoxItem Tag="urd">Urdu</ComboBoxItem>
                                                            <ComboBoxItem Tag="vie">Vietnamese</ComboBoxItem>
                                                        </ComboBox.Items>
                                                    </ComboBox>
                                                </StackPanel>
                                                <StackPanel Orientation="Vertical" HorizontalAlignment="Center">
                                                    <Button x:Name="GetSubsButton" Click="GetSubs_Click" FontWeight="Bold" Content="Search subtitle for the current movie..." Margin="5" VerticalAlignment="Center"/>
                                                    <TextBlock Foreground="Navy" Text="New subtitle file will overwrite existing one (if any)" FontSize="10"/>
                                                </StackPanel>
                                                <StackPanel Orientation="Horizontal" Margin="0 80 0 0">
                                                    <TextBlock Foreground="Black" Text="Subtitles service offered by " HorizontalAlignment="Right" VerticalAlignment="Center"/>
                                                    <Button x:Name="opensubsButton" Click="opensubsButton_Click" HorizontalAlignment="Right" Margin="5 0 0 0">
                                                        <Button.Template>
                                                            <ControlTemplate>
                                                                <Image Source="/images/opensubtitles.png" Width="150" Cursor="Hand"/>
                                                            </ControlTemplate>
                                                        </Button.Template>
                                                    </Button>
                                                </StackPanel>
                                            </StackPanel>
                                        </GroupBox>
                                    </StackPanel>
                                </ScrollViewer>
                            </ad:DockableContent>
                            <ad:DockableContent IsCloseable="False" x:Name="dcMediainfo" Title="Media Info" Icon="/Images/mediainfo.png" Focusable="False">
                                <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Focusable="False">
                                    <local:MediaInfoControl HorizontalAlignment="Stretch" VerticalAlignment="Stretch" x:Name="MediaInfoControl" AllowEditing="True"
                                  DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Window}},Path=CurrentMoviePath}"/>
                                </ScrollViewer>
                            </ad:DockableContent>
                            <ad:DockableContent IsCloseable="False" x:Name="dcMetadata" Title="Metadata" Icon="/Images/metadata.gif" Focusable="False">
                                <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Focusable="False">
                                    <WrapPanel>
                                        <WrapPanel.CommandBindings>
                                            <CommandBinding Command="{x:Static local:ResultsListBox.UseFromMetadataRoutedCommand}" Executed="ExecutedUseFromMetadataCommand" CanExecute="CanExecuteUseFromMetadataCommand"/>
                                        </WrapPanel.CommandBindings>
                                        <GroupBox Header="Movie Metadata" Style="{StaticResource GroupBoxStyle}" Margin="3" >
                                            <local:MetadataControl x:Name="MainMetadataControl" IsMain="True"/>
                                        </GroupBox>
                                        <GroupBox Header="Spare Metadata" Style="{StaticResource GroupBoxStyle}" Margin="3">
                                            <local:MetadataControl x:Name="ParentFolderMetadataControl" IsMain="False"/>
                                        </GroupBox>
                                    </WrapPanel>
                                </ScrollViewer>
                            </ad:DockableContent>
                        </ad:DockablePane>
                    </ad:ResizingPanel>
                </ad:ResizingPanel>

                <ad:ResizingPanel Orientation="Vertical">
                    <ad:DockablePane>
                        <ad:DockableContent IsCloseable="False" x:Name="dcMovieinfo" Title="Movie Information" Icon="/Images/movie.png">
                            <local:MovieInfoControl x:Name="MovieInfoControl"
                              VerticalAlignment="Stretch" VerticalContentAlignment="Stretch" ScrollViewer.VerticalScrollBarVisibility="Auto"
                                  CurrentMoviePath="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Window}},Path=CurrentMoviePath}"
                                  CurrentMovieItem="{Binding ElementName=ResultsTree, Path=SelectedItem, Mode=OneWay}"
                                  IMDBInfo="{Binding ElementName=TheWindow,Path=IMDBData, Mode=OneWay}"
                                  PrefCollectorInfo="{Binding ElementName=TheWindow,Path=PrefCollectorMovieInfo, Mode=OneWay}"
                                  MetadataInfo="{Binding ElementName=TheWindow,Path=MetadataInfo, Mode=OneWay}"
                                  PreviewMouseLeftButtonDown="Source_PreviewMouseLeftButtonDown"
                                  PreviewMouseMove="MovieInfoControl_PreviewMouseMove"
                                  MediaInfo="{Binding ElementName=MediaInfoControl,Path=MediaData,Mode=TwoWay}"/>
                        </ad:DockableContent>
                    </ad:DockablePane>
                    <ad:DockablePane>
                        <ad:DockableContent IsCloseable="False" x:Name="dcMoviesheetEditor" Title="Moviesheet Editor">
                            <Grid>
                                <Grid ShowGridLines="False" Margin="5"
          Visibility="{Binding Source={x:Static local:FileManager.EnableMovieSheets}, Converter={StaticResource BoolVisibilityConverter}}">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="*"/>
                                        <RowDefinition Height="Auto"/>
                                    </Grid.RowDefinitions>
                                    <TabControl Grid.Row="1" x:Name="MoviesheetsEditorTabControl" SelectionChanged="MoviesheetsEditorTabControl_SelectionChanged">
                                        <TabItem>
                                            <TabItem.HeaderTemplate>
                                                <DataTemplate>
                                                    <StackPanel Orientation="Horizontal">
                                                        <Image Source="/images/backdrop.png" VerticalAlignment="Center" Width="16" Height="16"/>
                                                        <TextBlock Margin="5 0 0 0" VerticalAlignment="Center" Text="Main sheet"/>
                                                    </StackPanel>
                                                </DataTemplate>
                                            </TabItem.HeaderTemplate>
                                            <Grid>
                                                <Grid.RowDefinitions>
                                                    <RowDefinition Height="Auto"/>
                                                    <RowDefinition Height="*"/>
                                                </Grid.RowDefinitions>
                                                <local:TemplateSelectorControl Grid.Row="0" x:Name="TemplatesCombo" Margin="5 0 0 0" LabelText="Template:"
                                       TemplatesSelectionChanged="TemplateSelectorControl_TemplatesSelectionChanged"
                                       ShowTvixieButton="True" HorizontalAlignment="Center" IsMainTemplateSelector="True"/>
                                                <Border Grid.Row="1" BorderBrush="White" BorderThickness="1" VerticalAlignment="Center" HorizontalAlignment="Center"
                            AllowDrop="True" DragEnter="Border_DragEnter" Drop="Border_Drop" Tag="Main">
                                                    <Image x:Name="MovieSheetSmallImage" Stretch="Uniform"/>
                                                </Border>
                                            </Grid>
                                        </TabItem>
                                        <TabItem Visibility="{Binding Source={x:Static local:FileManager.Configuration},Path=Options.AutogenerateMoviesheetForFolder,Converter={StaticResource BoolVisibilityConverter}}">
                                            <TabItem.HeaderTemplate>
                                                <DataTemplate>
                                                    <StackPanel Orientation="Horizontal">
                                                        <Image Source="/images/moviesheet_folder.png" VerticalAlignment="Center" Width="16" Height="16"/>
                                                        <TextBlock Margin="5 0 0 0" VerticalAlignment="Center" Text="Extra sheet"/>
                                                    </StackPanel>
                                                </DataTemplate>
                                            </TabItem.HeaderTemplate>
                                            <Grid>
                                                <Grid.RowDefinitions>
                                                    <RowDefinition Height="Auto"/>
                                                    <RowDefinition Height="*"/>
                                                </Grid.RowDefinitions>
                                                <local:TemplateSelectorControl Grid.Row="0" x:Name="TemplatesComboExtra" Margin="5 0 0 0" LabelText="Template:"
                                       TemplatesSelectionChanged="TemplateSelectorControl_ExtraTemplatesSelectionChanged"
                                       ShowTvixieButton="True" HorizontalAlignment="Center" IsMainTemplateSelector="False"/>
                                                <Border Grid.Row="1" BorderBrush="White" BorderThickness="1" VerticalAlignment="Center" HorizontalAlignment="Center"
                            AllowDrop="True" DragEnter="Border_DragEnter" Drop="Border_Drop" Tag="Main">
                                                    <Image x:Name="ExtraMovieSheetSmallImage" Stretch="Uniform"/>
                                                </Border>
                                            </Grid>
                                        </TabItem>
                                        <TabItem>
                                            <TabItem.HeaderTemplate>
                                                <DataTemplate>
                                                    <StackPanel Orientation="Horizontal">
                                                        <Image Source="/images/folder.png" VerticalAlignment="Center" Width="16" Height="16"/>
                                                        <TextBlock Margin="5 0 0 0" VerticalAlignment="Center" Text="Spare sheet"/>
                                                    </StackPanel>
                                                </DataTemplate>
                                            </TabItem.HeaderTemplate>
                                            <Grid>
                                                <Grid.RowDefinitions>
                                                    <RowDefinition Height="Auto"/>
                                                    <RowDefinition Height="*"/>
                                                </Grid.RowDefinitions>
                                                <local:TemplateSelectorControl Grid.Row="0" x:Name="TemplatesComboParentFolder" Margin="5 0 0 0" LabelText="Template:"
                                       TemplatesSelectionChanged="TemplatesComboParentFolder_TemplatesSelectionChanged"
                                       ShowTvixieButton="True" HorizontalAlignment="Center" IsMainTemplateSelector="False"/>
                                                <Border Grid.Row="1" BorderBrush="White" BorderThickness="1" VerticalAlignment="Center" HorizontalAlignment="Center"
                            AllowDrop="True" DragEnter="Border_DragEnter" Drop="Border_Drop" Tag="ParentFolder">
                                                    <Image x:Name="ParentFolderMovieSheetSmallImage" Stretch="Uniform"/>
                                                </Border>
                                            </Grid>
                                        </TabItem>
                                    </TabControl>

                                    <Grid Grid.Row="2" x:Name="grdMoviesheetGen" HorizontalAlignment="Center">

                                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Top">
                                            <CheckBox HorizontalAlignment="Left" VerticalAlignment="Center" ToolTip="Auto refresh moviesheets previews when their data is changing"
                              IsChecked="{Binding MovieSheetsOptions.AutorefreshPreview}" Margin="0 0 20 0">
                                                <TextBlock VerticalAlignment="Center" Text="Autorefresh"/>
                                            </CheckBox>
                                            <Border BorderThickness="1" BorderBrush="DarkGray" Padding="1" Margin="2" x:Name="TheMainSheetGenerateBtn">
                                                <Grid >
                                                    <Grid.ColumnDefinitions>
                                                        <ColumnDefinition Width="Auto"/>
                                                        <ColumnDefinition Width="Auto"/>
                                                        <ColumnDefinition Width="Auto"/>
                                                        <ColumnDefinition Width="Auto"/>
                                                        <ColumnDefinition Width="Auto"/>
                                                        <ColumnDefinition Width="Auto"/>
                                                        <ColumnDefinition Width="Auto"/>
                                                    </Grid.ColumnDefinitions>
                                                    <Grid.RowDefinitions>
                                                        <RowDefinition Height="Auto"/>
                                                        <RowDefinition Height="Auto"/>
                                                    </Grid.RowDefinitions>

                                                    <Image Grid.Column="0" Grid.Row="0" Source="/images/backdrop.png" Width="16" Height="16" Margin="2"
                      HorizontalAlignment="Center" ToolTip="Generate main moviesheet"/>
                                                    <CheckBox Grid.Column="0" Grid.Row="1" HorizontalAlignment="Center" IsChecked="{Binding AutogenerateMovieSheet}"
                      ToolTip="Generate main moviesheet"/>

                                                    <Image Grid.Column="1" Grid.Row="0" Source="/images/moviesheet_folder.png" Width="16" Height="16" Margin="2"
                      HorizontalAlignment="Center" ToolTip="Generate moviesheet for the extra location (see Advanced Options)"/>
                                                    <CheckBox Grid.Column="1" Grid.Row="1" HorizontalAlignment="Center" IsChecked="{Binding AutogenerateMoviesheetForFolder}"
                      ToolTip="Generate moviesheet for the extra location (see Advanced Options)"/>

                                                    <Image Grid.Column="2" Grid.Row="0" Source="/images/metadata.gif" Width="16" Height="16" Margin="2"
                      HorizontalAlignment="Center" ToolTip="Generate moviesheet metadata"/>
                                                    <CheckBox Grid.Column="2" Grid.Row="1" HorizontalAlignment="Center" IsChecked="{Binding AutogenerateMoviesheetMetadata}"
                      ToolTip="Generate moviesheet metadata"/>

                                                    <Button Grid.Column="3" Grid.ColumnSpan="5" Grid.Row="0" Grid.RowSpan="2"
                      x:Name="GenerateMovieSheetButton" FontWeight="Bold" Margin="2" VerticalAlignment="Center"
                      Click="GenerateMovieSheetButton_Click" ToolTip="Generate the selected moviesheets and/or metadata">
                                                        <StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
                                                            <!--<Image Source="/Images/backdrop.png" VerticalAlignment="Center"/>-->
                                                            <TextBlock FontWeight="Bold" Text="&lt;- Generate" Margin="2 0 0 0" VerticalAlignment="Center"/>
                                                        </StackPanel>
                                                    </Button>
                                                </Grid>
                                            </Border>
                                            <Border BorderThickness="1" BorderBrush="DarkGray" Padding="1" Margin="2" x:Name="TheParentFolderSheetGenerateBtn" Visibility="Collapsed">
                                                <Grid >
                                                    <Grid.ColumnDefinitions>
                                                        <ColumnDefinition Width="Auto"/>
                                                        <ColumnDefinition Width="Auto"/>
                                                    </Grid.ColumnDefinitions>
                                                    <Grid.RowDefinitions>
                                                        <RowDefinition Height="Auto"/>
                                                        <RowDefinition Height="Auto"/>
                                                    </Grid.RowDefinitions>

                                                    <Image Grid.Column="0" Grid.Row="0" Source="/images/metadata.gif" Width="16" Height="16" Margin="2"
                      HorizontalAlignment="Center" ToolTip="Generate spare metadata"/>
                                                    <CheckBox Grid.Column="0" Grid.Row="1" HorizontalAlignment="Center" IsChecked="{Binding GenerateParentFolderMetadata}"
                      ToolTip="Generate spare metadata"/>

                                                    <Button Grid.Column="1" Grid.ColumnSpan="5" Grid.Row="0" Grid.RowSpan="2"
                      x:Name="ParentFolderSheetGenerateBtn" FontWeight="Bold" Margin="2" VerticalAlignment="Center"
                      Click="ParentFolderSheetGenerateBtn_Click" ToolTip="Generate the spare moviesheet">
                                                        <StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
                                                            <TextBlock FontWeight="Bold" Text="&lt;- Generate" Margin="2 0 0 0" VerticalAlignment="Center"/>
                                                        </StackPanel>
                                                    </Button>
                                                </Grid>
                                            </Border>
                                            <Button x:Name="RefreshMovieSheetButton" VerticalAlignment="Center" Click="RefreshMovieSheetButton_Click" ToolTip="Refresh the moviesheet preview">
                                                <Border BorderBrush="Red">
                                                    <Border.Style>
                                                        <Style TargetType="Border">
                                                            <Style.Triggers>
                                                                <DataTrigger Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=MainGenerator.NeedsRender}" Value="True">
                                                                    <Setter Property="BorderThickness" Value="1"/>
                                                                </DataTrigger>
                                                            </Style.Triggers>
                                                            <Setter Property="BorderThickness" Value="0"/>
                                                        </Style>
                                                    </Border.Style>

                                                    <Image Source="/images/refresh.png" Width="16" Height="16" VerticalAlignment="Center"/>
                                                </Border>
                                            </Button>
                                            <Button x:Name="PreviewMovieSheetButton" Margin="2" Click="PreviewMovieSheetButton_Click"
                  ToolTip="Preview full moviesheet" VerticalAlignment="Center">
                                                <Image Source="/images/view.png" VerticalAlignment="Center" Width="16" Height="16"/>
                                            </Button>
                                            <Button x:Name="SaveMovieSheetButton" Margin="2" Click="SaveMovieSheetButton_Click"
                  ToolTip="Save original moviesheet to disk somewhere" VerticalAlignment="Center">
                                                <Image Source="/images/save.png" VerticalAlignment="Center" Width="16" Height="16"/>
                                            </Button>
                                            <Button Content="Tools..." VerticalAlignment="Center" x:Name="btnTools" Click="btnTools_Click">
                                                <Button.ContextMenu>
                                                    <ContextMenu>
                                                        <MenuItem Header="Reset all moviesheet data" Click="ResetMovieSheetButton_Click">
                                                            <MenuItem.Icon>
                                                                <Image Source="/images/reset.png" Width="16" Height="16"/>
                                                            </MenuItem.Icon>
                                                        </MenuItem>
                                                        <MenuItem Header="Reset cover image" Click="ResetImage_Click" Tag="Cover">
                                                            <MenuItem.Icon>
                                                                <Image Source="/images/del.png" Width="16" Height="16"/>
                                                            </MenuItem.Icon>
                                                        </MenuItem>
                                                        <MenuItem Header="Reset background" Click="ResetImage_Click" Tag="Background">
                                                            <MenuItem.Icon>
                                                                <Image Source="/images/del.png" Width="16" Height="16"/>
                                                            </MenuItem.Icon>
                                                        </MenuItem>
                                                        <MenuItem Header="Reset fanart 1" Click="ResetImage_Click" Tag="Fanart1">
                                                            <MenuItem.Icon>
                                                                <Image Source="/images/del.png" Width="16" Height="16"/>
                                                            </MenuItem.Icon>
                                                        </MenuItem>
                                                        <MenuItem Header="Reset fanart 2" Click="ResetImage_Click" Tag="Fanart2">
                                                            <MenuItem.Icon>
                                                                <Image Source="/images/del.png" Width="16" Height="16"/>
                                                            </MenuItem.Icon>
                                                        </MenuItem>
                                                        <MenuItem Header="Reset fanart 3" Click="ResetImage_Click" Tag="Fanart3">
                                                            <MenuItem.Icon>
                                                                <Image Source="/images/del.png" Width="16" Height="16"/>
                                                            </MenuItem.Icon>
                                                        </MenuItem>
                                                        <Separator/>
                                                        <MenuItem Header="Flip horizontally the background image" Click="FlipImage_Click" Tag="Background">
                                                            <MenuItem.Icon>
                                                                <Image Source="/images/flipX.png" Width="16" Height="16"/>
                                                            </MenuItem.Icon>
                                                        </MenuItem>
                                                        <MenuItem Header="Flip horizontally the fanart1 image" Click="FlipImage_Click" Tag="Fanart1">
                                                            <MenuItem.Icon>
                                                                <Image Source="/images/flipX.png" Width="16" Height="16"/>
                                                            </MenuItem.Icon>
                                                        </MenuItem>
                                                        <MenuItem Header="Flip horizontally the fanart2 image" Click="FlipImage_Click" Tag="Fanart2">
                                                            <MenuItem.Icon>
                                                                <Image Source="/images/flipX.png" Width="16" Height="16"/>
                                                            </MenuItem.Icon>
                                                        </MenuItem>
                                                        <MenuItem Header="Flip horizontally the fanart3 image" Click="FlipImage_Click" Tag="Fanart3">
                                                            <MenuItem.Icon>
                                                                <Image Source="/images/flipX.png" Width="16" Height="16"/>
                                                            </MenuItem.Icon>
                                                        </MenuItem>
                                                    </ContextMenu>
                                                </Button.ContextMenu>
                                            </Button>
                                        </StackPanel>
                                    </Grid>
                                </Grid>
                                <Grid VerticalAlignment="Center" HorizontalAlignment="Center"
              Visibility="{Binding Source={x:Static local:FileManager.EnableMovieSheets}, Converter={StaticResource NotBoolVisibilityConverter}}">
                                    <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center">
                    <Run>MovieSheets support is disabled!</Run>
                    <LineBreak/>
                    <Run>For details visit http://thumbgen.blogspot.com or</Run>
                    <LineBreak/>
                    <Run>http://wdtvforum.com</Run>
                                    </TextBlock>
                                </Grid>
                            </Grid>
                        </ad:DockableContent>
                    </ad:DockablePane>
                </ad:ResizingPanel>
            </ad:ResizingPanel>
        </ad:DockingManager>

    </Grid>

</fluent:RibbonWindow>

